package org.dromara.mall.util;

import org.apache.commons.codec.binary.Base32;
import org.apache.commons.codec.digest.HmacUtils;


public class HybridCodeUtil {
    private static final Base32 base32 = new Base32(); // Apache Commons Codec

    public static String generate(String phone) {
        byte[] hash = HmacUtils.getHmacSha256("woaisanpiguanaiwolaiyiguan".getBytes())
            .doFinal(phone.getBytes());
        return base32.encodeAsString(hash)
            .replace("=", "")
            .substring(0, 8);
    }


    public static void main(String[] args) {
        System.out.println(HybridCodeUtil.generate("13728614523"));
    }
}
